﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Convert.CPIAMmodel
{
    public class Suppliers
    {
        public Suppliers(int SupplierID, string SupplierName, string SupAddress, string SupSuburb, string SupState, string SupPostCode, string SupPhoneNumber, string SupFaxNumber, string SupAccNo, string SupAccPass, string PharmXOrderCode)
        {
            this.SupplierNo = Guid.NewGuid();
            this.SupplierName = SupplierName;
            this.SupContactName = String.Empty;
            this.SupAddress = SupAddress;
            this.SupSuburb = SupSuburb;
            this.SupState = SupState;
            this.SupPostCode = SupPostCode;
            this.SupPhoneNumber = SupPhoneNumber;
            this.SupFaxNumber = SupFaxNumber;
            this.SupXRef = "N/A";
            this.SupAccNo = SupAccNo;
            this.SupAccPass = SupAccPass;
            this.SupAccNoTwo = "000000";
            this.SupAccPassTwo = "N/A";
            this.PharmXOrderCode = PharmXOrderCode;
            this.PharmXOrderMethod = "N/A";
            this.PharmXOrderType = "N/A";
            this.PharmXOrderBUP = "N/A";
            this.PharmXActive = false;
            this.PharmXSuppID = 0;
            this.PharmXOrderGroup = "N/A";
            this.SupplierID = SupplierID;
            this.SupIsSystem = false;
            this.IGANumber = 0;
        }
        /*
        public Guid SupplierNo{ get; set; }
        public string SupplierName{ get; set; }
        public string SupContactName{ get; set; }
        public string SupAddress{ get; set; }
        public string SupSuburb{ get; set;}
        public string SupState{ get; set;} 
        public string SupPostCode{ get; set;}
        public string SupPhoneNumber{ get; set; }
        public string SupFaxNumber{ get; set; } 
        public string SupXRef{ get; set; }
        public string SupAccNo{ get; set; }
        public string SupAccPass{ get; set; }
        public string SupAccNoTwo{ get; set; }
        public string SupAccPassTwo{ get; set; }
        public string PharmXOrderCode{ get; set; }
        public string PharmXOrderMethod{ get; set; }
        public string PharmXOrderType{ get; set; }
        public string PharmXOrderBUP{ get; set; }
        public Boolean PharmXActive{ get; set; }
        public int PharmXSuppID{ get; set; }
        public string PharmXOrderGroup{ get; set; }
        public int SupplierID{ get; set; }
        */
        private Guid _SupplierNo;

        public Guid SupplierNo
        {
            get { return _SupplierNo; }
            set { _SupplierNo = value; }
        }
        private string _SupplierName;

        public string SupplierName
        {
            get { return _SupplierName; }
            set
            {
                _SupplierName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupplierName.Length > 50)
                    _SupplierName = _SupplierName.Substring(0, 50);
            }
        }

        private string _SupContactName;

        public string SupContactName
        {
            get { return _SupContactName; }
            set
            {
                _SupContactName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupContactName.Length > 50)
                    _SupContactName = _SupContactName.Substring(0, 50);
            }
        }

        private string _SupAddress;

        public string SupAddress
        {
            get { return _SupAddress; }
            set
            {
                _SupAddress = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupAddress.Length > 255)
                    _SupAddress = _SupAddress.Substring(0, 255);
            }
        }

        private string _SupSuburb;

        public string SupSuburb
        {
            get { return _SupSuburb; }
            set
            {
                _SupSuburb = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupSuburb.Length > 50)
                    _SupSuburb = _SupSuburb.Substring(0, 50);
            }
        }
        private string _SupState;

        public string SupState
        {
            get { return _SupState; }
            set
            {
                _SupState = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupState.Length > 5)
                    _SupState = _SupState.Substring(0, 5);
            }
        }
        private string _SupPostCode;

        public string SupPostCode
        {
            get { return _SupPostCode; }
            set
            {
                _SupPostCode = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupPostCode.Length > 50)
                    _SupPostCode = _SupPostCode.Substring(0, 50);
            }
        }
        private string _SupPhoneNumber;

        public string SupPhoneNumber
        {
            get { return _SupPhoneNumber; }
            set
            {
                _SupPhoneNumber = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupPhoneNumber.Length > 50)
                    _SupPhoneNumber = _SupPhoneNumber.Substring(0, 50);
            }
        }
        private string _SupFaxNumber;

        public string SupFaxNumber
        {
            get { return _SupFaxNumber; }
            set
            {
                _SupFaxNumber = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupFaxNumber.Length > 50)
                    _SupFaxNumber = _SupFaxNumber.Substring(0, 50);
            }
        }
        private string _SupXRef;

        public string SupXRef
        {
            get { return _SupXRef; }
            set
            {
                _SupXRef = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupXRef.Length > 50)
                    _SupXRef = _SupXRef.Substring(0, 50);
            }
        }
        private string _SupAccNo;

        public string SupAccNo
        {
            get { return _SupAccNo; }
            set
            {
                _SupAccNo = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupAccNo.Length > 50)
                    _SupAccNo = _SupAccNo.Substring(0, 50);
            }
        }
        private string _SupAccPass;

        public string SupAccPass
        {
            get { return _SupAccPass; }
            set
            {
                _SupAccPass = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupAccPass.Length > 50)
                    _SupAccPass = _SupAccPass.Substring(0, 50);
            }
        }
        private string _SupAccNoTwo;

        public string SupAccNoTwo
        {
            get { return _SupAccNoTwo; }
            set
            {
                _SupAccNoTwo = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupAccNoTwo.Length > 50)
                    _SupAccNoTwo = _SupAccNoTwo.Substring(0, 50);
            }
        }
        private string _SupAccPassTwo;

        public string SupAccPassTwo
        {
            get { return _SupAccPassTwo; }
            set
            {
                _SupAccPassTwo = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_SupAccPassTwo.Length > 50)
                    _SupAccPassTwo = _SupAccPassTwo.Substring(0, 50);
            }
        }
        private string _PharmXOrderCode;

        public string PharmXOrderCode
        {
            get { return _PharmXOrderCode; }
            set
            {
                _PharmXOrderCode = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_PharmXOrderCode.Length > 50)
                    _PharmXOrderCode = _PharmXOrderCode.Substring(0, 50);
            }
        }
        private string _PharmXOrderMethod;

        public string PharmXOrderMethod
        {
            get { return _PharmXOrderMethod; }
            set
            {
                _PharmXOrderMethod = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_PharmXOrderMethod.Length > 50)
                    _PharmXOrderMethod = _PharmXOrderMethod.Substring(0, 50);
            }
        }
        private string _PharmXOrderType;

        public string PharmXOrderType
        {
            get { return _PharmXOrderType; }
            set
            {
                _PharmXOrderType = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_PharmXOrderType.Length > 50)
                    _PharmXOrderType = _PharmXOrderType.Substring(0, 50);
            }
        }
        private string _PharmXOrderBUP;

        public string PharmXOrderBUP
        {
            get { return _PharmXOrderBUP; }
            set
            {
                _PharmXOrderBUP = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_PharmXOrderBUP.Length > 50)
                    _PharmXOrderBUP = _PharmXOrderBUP.Substring(0, 50);
            }
        }
        private Boolean _PharmXActive;

        public Boolean PharmXActive
        {
            get { return _PharmXActive; }
            set { _PharmXActive = value; }
        }
        private int _PharmXSuppID;

        public int PharmXSuppID
        {
            get { return _PharmXSuppID; }
            set { _PharmXSuppID = value; }
        }
        private string _PharmXOrderGroup;

        public string PharmXOrderGroup
        {
            get { return _PharmXOrderGroup; }
            set
            {
                _PharmXOrderGroup = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_PharmXOrderGroup.Length > 50)
                    _PharmXOrderGroup = _PharmXOrderGroup.Substring(0, 50);
            }
        }
        private int _SupplierID;

        public int SupplierID
        {
            get { return _SupplierID; }
            set { _SupplierID = value; }
        }

        private Boolean _SupIsSystem;

        public Boolean SupIsSystem
        {
            get { return _SupIsSystem; }
            set { _SupIsSystem = value; }
        }
        private int _IGANumber;

        public int IGANumber
        {
            get { return _IGANumber; }
            set { _IGANumber = value; }
        }

        public static void SaveSuppliersToDataTable(Suppliers suppliers, DataTable SuppliersDT)
        {
            SuppliersDT.Rows.Add(suppliers.SupplierNo, suppliers.SupplierID, suppliers.SupplierName, suppliers.SupContactName, suppliers.SupAddress, suppliers.SupSuburb, suppliers.SupState, suppliers.SupPostCode, suppliers.SupPhoneNumber, suppliers.SupXRef, suppliers.SupAccNo, suppliers.SupAccPass, suppliers.SupAccNoTwo, suppliers.SupAccPassTwo, suppliers.PharmXOrderCode, suppliers.PharmXOrderMethod, suppliers.PharmXOrderType, suppliers.PharmXOrderBUP, suppliers.PharmXActive, suppliers.PharmXSuppID, suppliers.PharmXOrderGroup,suppliers.SupIsSystem,suppliers.IGANumber);
        }
    }

    public class Manufacturers
    {
        //public Guid ManfNo { get; set; }
        //public string ManfCode { get; set; }
        //public string ManfName { get; set; }

        public Manufacturers(string ManfCode, string ManfName) 
        {
            this.ManfNo = Guid.NewGuid();
            this.ManfCode = ManfCode;
            this.ManfName = ManfName;
        }

        private Guid _ManfNo;

        public Guid ManfNo
        {
            get { return _ManfNo; }
            set { _ManfNo = value; }
        }
        private string _ManfCode;

        public string ManfCode
        {
            get { return _ManfCode; }
            set
            {
                _ManfCode = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ManfCode.Length > 50)
                    _ManfCode = _ManfCode.Substring(0, 50);
            }
        }
        private string _ManfName;

        public string ManfName
        {
            get { return _ManfName; }
            set
            {
                _ManfName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ManfName.Length > 50)
                    _ManfName = _ManfName.Substring(0, 50);
            }
        }

        public static void SaveManufacturersToDataTable(Manufacturers manufacturers, DataTable ManufacturersDataTable)
        {
            ManufacturersDataTable.Rows.Add(manufacturers.ManfNo,manufacturers.ManfCode,manufacturers.ManfName);
        }
    }

    public class AgentFile
    {
        //public Guid AgentID { get; set; }
        //public string AgentName { get; set; }

        public AgentFile(string AgentName)
        {
            this.AgentID = Guid.NewGuid();
            this.AgentName = AgentName;
        }

        private Guid _AgentID;

        public Guid AgentID
        {
            get { return _AgentID; }
            set { _AgentID = value; }
        }

        private string _AgentName;

        public string AgentName
        {
            get { return _AgentName; }
            set
            {
                _AgentName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_AgentName.Length > 100)
                    _AgentName = _AgentName.Substring(0, 100);
            }
        }

        public static void SaveAgentFileToDataTable(AgentFile agentFile, DataTable AgentFileDT)
        {
            AgentFileDT.Rows.Add(agentFile.AgentID, agentFile.AgentName);
        }
    }

    public class Categories
    {
        //public string StockCatName { get; set; }

        public Categories(string StockCatName)
        {
            this.StockCatName = StockCatName;
        }
        private string _StockCatName;

        public string StockCatName
        {
            get { return _StockCatName; }
            set
            {
                _StockCatName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_StockCatName.Length > 100)
                    _StockCatName = _StockCatName.Substring(0, 100);
            }
        }

        public static void SaveCategoriesToDataTable(Categories categories, DataTable CategoriesDT)
        {
            CategoriesDT.Rows.Add(categories.StockCatName);
        }

    }

    public class DebtorGroups
    {
        //public Guid DebtGrID { get; set; } 
        //public string DebtGrpName { get; set;}
        //public string DebtGrCode { get; set; }

        public DebtorGroups(string DebtGrpName, string DebtGrCode)
        {
            this.DebtGrID = Guid.NewGuid();
            this.DebtGrpName = DebtGrpName;
            this.DebtGrCode = DebtGrCode;
        }

        private Guid _DebtGrID;

        public Guid DebtGrID
        {
            get { return _DebtGrID; }
            set { _DebtGrID = value; }
        }

        private string _DebtGrpName;

        public string DebtGrpName
        {
            get { return _DebtGrpName; }
            set
            {
                _DebtGrpName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DebtGrpName.Length > 50)
                    _DebtGrpName = _DebtGrpName.Substring(0, 50);
            }
        }

        private string _DebtGrCode;

        public string DebtGrCode
        {
            get { return _DebtGrCode; }
            set
            {
                _DebtGrCode = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DebtGrCode.Length > 50)
                    _DebtGrCode = _DebtGrCode.Substring(0, 50);
            }
        }

        public static void SaveDebtorGroupsToDataTable(DebtorGroups debtorGroups, DataTable DebtorGroupsDT)
        {
            DebtorGroupsDT.Rows.Add(debtorGroups.DebtGrID, debtorGroups.DebtGrpName, debtorGroups.DebtGrCode);
        }
    }

    public class DeptGroups
    {
        //public Guid DeptGroupID { get; set; }
        //public string DeptGroupName { get; set; }
        //public int DeptGroupNo { get; set; }

        public DeptGroups(string DeptGroupName, int DeptGroupNo)
        {
            this.DeptGroupID = Guid.NewGuid();
            this.DeptGroupName = DeptGroupName;
            this.DeptGroupNo = DeptGroupNo;
        }

        private Guid _DeptGroupID;

        public Guid DeptGroupID
        {
            get { return _DeptGroupID; }
            set { _DeptGroupID = value; }
        }

        private string _DeptGroupName;

        public string DeptGroupName
        {
            get { return _DeptGroupName; }
            set
            {
                _DeptGroupName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DeptGroupName.Length > 100)
                    _DeptGroupName = _DeptGroupName.Substring(0, 100);
            }
        }

        private int _DeptGroupNo;

        public int DeptGroupNo
        {
            get { return _DeptGroupNo; }
            set { _DeptGroupNo = value; }
        }

        public static void SaveDeptGroupsToDataTable(DeptGroups deptGroup, DataTable deptGroupDataTable)
        {
            deptGroupDataTable.Rows.Add(deptGroup.DeptGroupID, deptGroup.DeptGroupName, deptGroup.DeptGroupNo);
        }
    }

    public class DeptFile
    {
        //public Guid DeptID { get; set; }
        //public int DeptNo { get; set; }
        //public string DeptName { get; set; }
        //public decimal DeptMp { get; set; }
        //public int DeptNoGroup { get; set; }
        public DeptFile(int DeptNo, string DeptName, decimal DeptMp, int DeptNoGroup)
        {
            this.DeptID=Guid.NewGuid();
            this.DeptNo = DeptNo;
            this.DeptName = DeptName;
            this.DeptMp = DeptMp;
            this.DeptNoGroup = DeptNoGroup;
        }

        private Guid _DeptID;

        public Guid DeptID
        {
            get { return _DeptID; }
            set { _DeptID = value; }
        }
        private int _DeptNo;

        public int DeptNo
        {
            get { return _DeptNo; }
            set { _DeptNo = value; }
        }
        private string _DeptName;

        public string DeptName
        {
            get { return _DeptName; }
            set
            {
                _DeptName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DeptName.Length > 50)
                    _DeptName = _DeptName.Substring(0, 50);
            }
        }
        private decimal _DeptMp;

        public decimal DeptMp
        {
            get { return _DeptMp; }
            set { _DeptMp = value; }
        }
        private int _DeptNoGroup;

        public int DeptNoGroup
        {
            get { return _DeptNoGroup; }
            set { _DeptNoGroup = value; }
        }

        public static void SaveDeptFileToDataTable(DeptFile deptFile, DataTable DeptFileDataTable)
        {
            DeptFileDataTable.Rows.Add(deptFile.DeptID,deptFile.DeptNo,deptFile.DeptName,deptFile.DeptMp,deptFile.DeptNoGroup);
        }
    }

    public class ClerkFile
    {
        public const string CLERK_GROUP_STAFF_MEMBER = "Staff Member";

        public const string CLERK_STATUS_ACTIVE = "A";

        public ClerkFile()
        {
        }

        public ClerkFile(Guid ClerkID, string clerkSurname, string clerkFirstname, string clerkCode, string clerkPhone, string clerkGroup, string clerkInitials)
        {
            this.ClerkID = ClerkID;
            this.ClerkSurname = clerkSurname;
            this.ClerkFirstName = clerkFirstname;
            this.ClerkPassWord = "0000";
            this.ClerkPWActive = false;
            this.ClerkCode = clerkCode;
            this.ClerkPhone = clerkPhone;
            this.ClerkStartDate = DateTime.Now;
            this.ClerkGroup = clerkGroup;
            this.ClerkRegistrationNo = "N/A";
            this.ClerkInitials = clerkInitials;
            this.ClerkStatus = CLERK_STATUS_ACTIVE;
        }
        /*
        public Guid ClerkID { get; set; }
        public string ClerkSurname { get; set; }
        public string ClerkFirstName { get; set; }
        public string ClerkPassWord { get; set; }
        public Boolean ClerkPWActive { get; set; }
        public string ClerkCode { get; set; }
        public string ClerkPhone { get; set; }
        public DateTime ClerkStartDate { get; set; }
        public string ClerkStatus { get; set; }
        public string ClerkGroup { get; set; }
        public string ClerkRegistrationNo { get; set; }
        public string ClerkInitials { get; set; }
        */
        private Guid _ClerkID;

        public Guid ClerkID
        {
            get { return _ClerkID; }
            set { _ClerkID = value; }
        }

        private string _ClerkSurname;
        public string ClerkSurname
        {
            get
            {
                return _ClerkSurname;
            }

            set
            {
                _ClerkSurname = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClerkSurname.Length > 100)
                    _ClerkSurname = _ClerkSurname.Substring(0, 100);
            }
        }

        private string _ClerkFirstName;
        public string ClerkFirstName
        {
            get
            {
                return _ClerkFirstName;
            }
            set
            {
                _ClerkFirstName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClerkFirstName.Length > 100)
                    _ClerkFirstName = _ClerkFirstName.Substring(0, 100);
            }
        }

        private string _ClerkPassWord;

        public string ClerkPassWord
        {
            get { return _ClerkPassWord; }
            set
            {
                _ClerkPassWord = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClerkPassWord.Length > 50)
                    _ClerkPassWord = _ClerkPassWord.Substring(0, 50);
            }
        }

        private Boolean _ClerkPWActive;

        public Boolean ClerkPWActive
        {
            get { return _ClerkPWActive; }
            set { _ClerkPWActive = value; }
        }

        private string _ClerkCode;

        public string ClerkCode
        {
            get { return _ClerkCode; }
            set
            {
                _ClerkCode = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClerkCode.Length > 50)
                    _ClerkCode = _ClerkCode.Substring(0, 50);
            }
        }

        private string _ClerkPhone;

        public string ClerkPhone
        {
            get { return _ClerkPhone; }
            set
            {
                _ClerkPhone = string.IsNullOrWhiteSpace(value) ? "0000000000" : value;
                if (_ClerkPhone.Length > 50)
                    _ClerkPhone = _ClerkPhone.Substring(0, 50);
            }
        }

        private DateTime _ClerkStartDate;

        public DateTime ClerkStartDate
        {
            get { return _ClerkStartDate; }
            set { _ClerkStartDate = value; }
        }

        private string _ClerkStatus;

        public string ClerkStatus
        {
            get { return _ClerkStatus; }
            set
            {
                _ClerkStatus = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClerkStatus.Length > 1)
                    _ClerkStatus = _ClerkStatus.Substring(0, 1);
            }
        }

        private string _ClerkGroup;

        public string ClerkGroup
        {
            get { return _ClerkGroup; }
            set
            {
                _ClerkGroup = string.IsNullOrWhiteSpace(value) ? CLERK_GROUP_STAFF_MEMBER : value;
                if (_ClerkGroup.Length > 50)
                    _ClerkGroup = _ClerkGroup.Substring(0, 50);
            }
        }

        private string _ClerkRegistrationNo;

        public string ClerkRegistrationNo
        {
            get { return _ClerkRegistrationNo; }
            set
            {
                _ClerkRegistrationNo = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClerkRegistrationNo.Length > 32)
                    _ClerkRegistrationNo = _ClerkRegistrationNo.Substring(0, 32);
            }
        }

        private string _ClerkInitials;

        public string ClerkInitials
        {
            get { return _ClerkInitials; }
            set
            {
                _ClerkInitials = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClerkInitials.Length > 10)
                    _ClerkInitials = _ClerkInitials.Substring(0, 10);
            }
        }

        public static void SaveClerkFileToDataTable(ClerkFile clerkFile, DataTable clerkDataTable)
        {
            clerkDataTable.Rows.Add(clerkFile.ClerkID, clerkFile.ClerkSurname, clerkFile.ClerkFirstName, clerkFile.ClerkPassWord, clerkFile.ClerkPWActive, clerkFile.ClerkCode, clerkFile.ClerkPhone, clerkFile.ClerkStartDate, clerkFile.ClerkStatus, clerkFile.ClerkGroup, clerkFile.ClerkRegistrationNo, clerkFile.ClerkInitials);
        }
    }
}
